<{include file="tpl/header.html"}>
<h2 class="ytadmin-h2"><{T w="Category"}></h2>

<div class="ytadmin-form-wrap">

	<form class="form-inline" role="form" action="<{spUrl c=category a=index}>" method="post">
	 	<div class="form-group">
	    	<label class="sr-only" for="cat_name"><{T w="Category"}> <{T w="Name"}>：</label>
	    	<input type="text" name="cat_name" class="form-control" id="cat_name" placeholder='<{T w="Category"}> <{T w="Name"}>'>
	  	</div>
	  	<div class="form-group">
			<label class="sr-only" for="cat_father_id"><{T w="Father Category"}>：</label>
			<select class="form-control" name="cat_father_id" id="cat_father_id">
				<{if $now_cat_info}>
					<option value='<{$now_cat_info["id"]}>'><{$now_cat_info['name']}></option>
				<{else}>
					<option value='0'><{T w="Top Category"}></option>
				<{/if}>
				<{foreach key=key item=cat_item from=$cat_result}>
					<{if $data_return['cat_father_id']==$cat_item['id']}>
						<option value="<{$cat_item['id']}>" selected="selected"><{$cat_item['name']}></option>
					<{else}>
						<option value="<{$cat_item['id']}>"><{$cat_item['name']}></option>
					<{/if}>
				<{/foreach}>

			</select>
		</div>
		<div class="form-group">
			<label class="sr-only" for="cat_module"><{T w="Module"}>：</label>

			<select class="form-control" name="cat_module" id="cat_module">
			<{if $now_cat_info}>
				<option value='<{$now_cat_info["module"]}>'><{$now_cat_info["module"]}></option>
			<{else}>
				<option value='article'><{T w="Article"}></option>
				<option value='picture'><{T w="Album"}></option>
				<option value='page'><{T w="Page"}></option>
				<option value='url'><{T w="Url"}></option>
		  	<{/if}>
		  	</select>
		  	
		</div>
		<div class="form-group">
	    	<label class="sr-only" for="cat_weight"><{T w="Order"}>：</label>
	    	<input type="text" name="cat_weight" class="form-control ytadmin-input-min" id="cat_weight" placeholder='<{T w="Order"}>'>
	  	</div>
		<div class="form-group">
			<input type="submit" name="cat_new_submit" class="btn btn-info" value='<{T w="Add"}>'/>
		</div>
	</form>
	
</div>
<div class="ytadmin-table-wrap">
	<table class="table table-striped">
		<tr>
			<th>ID</th>
			<th><{T w="Module"}></th>
			<th><{T w="Name"}>/<{T w="Order"}></th>
			<th><{T w="Son"}> <{T w="Category"}></th>
			<th><{T w="Visibility"}></th>
			<th><{T w="Opera"}></th>
		</tr>
		<{foreach item=cat_item from=$cat_result}>
		<tr>
			<td><{$cat_item['id']}></td>
			<td>
				<{if $cat_item['module']=='0'}>
					<{T w="None"}>
				<{elseif $cat_item['module']=='article'}>
					<{T w="Article"}>
				<{elseif $cat_item['module']=='picture'}>
					<{T w="Album"}>
				<{elseif $cat_item['module']=='page'}>
					<{T w="Page"}>
				<{elseif $cat_item['module']=='url'}>
					<{T w="Url"}>
				<{/if}>
			</td>
			<td>
				<form class="form-inline" action="<{spUrl c=category a=index}>" method="post">
					<div class="form-group">
						<{if $cat_item['id']==1}>
							<input class="form-control input-sm" type="text" readonly name="cat_name" value="<{$cat_item['name']}>"/>
						<{else}>
							<input class="form-control input-sm" type="text" name="cat_name" value="<{$cat_item['name']}>"/>
						<{/if}>
					</div>
					<div class="form-group">
						<{T w="Order"}>：
						<input class="form-control input-sm ytadmin-input-min" type="text" name="weight" value="<{$cat_item['weight']}>" />	
					</div>
					<input type="hidden" name="cat_id" value="<{$cat_item['id']}>"/>
					<input type="submit" name="cat_update" class="btn btn-sm" value="<{T w='Update'}>"/>
				</form>
			</td>
			<td>
				<{if $cat_item['cat_son_count']!=0}>
					<a href="<{spUrl c=category a=index now_cat_id=$cat_item['id']}>" class="btn btn-info btn-sm"><{T w="View"}> [<{$cat_item['cat_son_count']}>]</a>
				<{/if}>
			</td>
			<td>
				<div class="btn-group">
					<{if $cat_item['visible']}>
						<a class="btn btn-info btn-sm"><{T w="Visible"}></a>
						<a href="<{spUrl c=category a=index cat_id=$cat_item['id'] cat_update=1 visible=0}>" class="btn btn-default btn-sm"><{T w="Hidden"}></a>
					<{else}>
						<a href="<{spUrl c=category a=index cat_id=$cat_item['id'] cat_update=1 visible=1}>" class="btn btn-default btn-sm"><{T w="Visible"}></a>
						<a href="" class="btn btn-info  btn-sm"><{T w="Hidden"}></a>
					<{/if}>
				</div>
			</td>
			<td>
				
				<form class="form-inline" action="<{spUrl c=category a=index}>" method="post">				
					<input type="hidden" name="cat_module" value="<{$cat_item['module']}>"/>
					<input type="hidden" name="cat_id" value="<{$cat_item['id']}>"/>					
					<input type="submit" name="cat_delete" class="btn btn-warning btn-sm" value="<{T w='Delete'}>"/>	 
				</form>
			
				
			</td>
		</tr>
		<{/foreach}>
	</table>
</div>
<{include file="tpl/footer.html"}>